package linuxbox.todo.servlet;

import javax.servlet.http.*;

import linuxbox.common.*;
import linuxbox.todo.logic.*;

public class BoxTodoCatAction
    extends Action
{
  protected static String viewJSP = null;
  protected static String adminJSP = null;
  protected static String editJSP = null;
  protected static String norightJSP = null;

  public void doAction(HttpSession aSession, BoxSession aBoxSession,
                       HttpServletRequest req, HttpServletResponse resp) throws
      Exception
  {
    String str = req.getParameter("SubmitCancel");
    if (str != null)
    {
      sendFile(viewJSP, req, resp);
      return;
    }

    str = (String) req.getParameter("SubmitSave");
    if (str != null)
    {
      //XTODO: check user rights
      BoxTodoCat home = new BoxTodoCat();
      home.setUserCategories(aBoxSession, req.getParameterValues("CATEGORIES"));
      sendFile(viewJSP, req, resp);
      return;
    }

    str = (String) req.getParameter("SubmitSysSave");
    if (str != null)
    {
      //XTODO: check user rights
      BoxTodoCat home = new BoxTodoCat();
      home.setSystemCategories(req.getParameterValues("CATEGORIES"));
      sendFile(adminJSP, req, resp);
      return;
    }

    str = (String) req.getParameter("SubmitEdit");
    if (str != null)
    {
      req.setAttribute("SYSTEMCAT", "0");
      sendFile(editJSP, req, resp);
      return;
    }

    str = (String) req.getParameter("SubmitSysEdit");
    if (str != null)
    {
      req.setAttribute("SYSTEMCAT", "1");
      sendFile(editJSP, req, resp);
      return;
    }
    sendFile(viewJSP, req, resp);
  }

  public void setViewJSP(String str)
  {
    viewJSP = str;
  }

  public void setEditJSP(String str)
  {
    editJSP = str;
  }

  public void setAdminJSP(String str)
  {
    adminJSP = str;
  }
}
